package cn.smart.epic.core.util;

import cn.smart.epic.config.properties.EpicProperties;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @Auther Uncle_Z
 * @date 2017/9/29 23:44
 * @Email:2545375@qq.com
 * @Descrition 高频方法集合类
 * @since 1.0
 */

public class ToolUtil {

    /**
     *
     * 获取异常的具体信息
     *
     * @param
     * @return
     * @Auther Z.B
     * @date 2017/9/29 23:45
     */
    public static String getExceptionMsg(Exception e){
        StringWriter sw = new StringWriter();
        try{
            e.printStackTrace(new PrintWriter(sw));
        }finally {
            try{
                sw.close();
            }catch (IOException e1){
                e1.printStackTrace();
            }
        }
        return sw.getBuffer().toString().replaceAll("\\$","T");
    }

    /**
     * 获取验证码开关
     *
     * @author stylefeng
     * @Date 2017/5/23 22:34
     */
    public static Boolean getKaptchaOnOff(){
        return SpringContextHolder.getBean(EpicProperties.class).isKaptchaOpen();
    }


}
